package com.my.selectcoursesystem.service.serviceImpl;

import com.my.selectcoursesystem.bean.SC;
import com.my.selectcoursesystem.dao.SCDao;
import com.my.selectcoursesystem.service.SCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("SCService")
public class SCServiceImpl implements SCService {
    @Autowired
    private SCDao scDao;

    public SCServiceImpl() {
    }

    public SCServiceImpl(SCDao scDao) {
        this.scDao = scDao;
    }

    @Override
    public SC insertSC(SC sc) {
        return this.scDao.save(sc);
    }

    @Override
    public Boolean deleteSCByCidAndSid(String cou_id, String stu_id) {
        try {
            this.scDao.deleteByCouidAndStuid(cou_id, stu_id);
        }catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    @Override
    public SC getSCByCidAndSid(String cou_id, String stu_id) {
        return this.scDao.findByCouidAndStuid(cou_id, stu_id);
    }
}
